﻿using System;
using System.Web;
using Microsoft.SharePoint;

namespace SPNotesFor
{
	/// <summary>
	/// Helper methods to write in the SharePoint ULS.
	/// </summary>
	static class SPLog
	{
		// correlation guid
		private static readonly Guid traceGuid = Guid.NewGuid();


		public static void DebugString(String message, params Object[] arguments)
		{
			LogString(TraceSeverity.Verbose, message, arguments);
		}

		public static void LogString(String message, params Object[] arguments)
		{
			LogString(TraceSeverity.Monitorable, message, arguments);
		}

		public static void LogString(TraceSeverity severity, String message, params Object[] arguments)
		{
			const string product = "SPNotesForSearchFilter";
			const string category = "Administration";
			const string exeName = "stsadm.exe";

			if (arguments.Length > 0)
				message = String.Format(message, arguments);


			//Write to sharepoint trace
			TraceProvider.RegisterTraceProvider();
			TraceProvider.WriteTrace(0, severity, traceGuid, exeName, product, category, message);
			TraceProvider.UnregisterTraceProvider();
		}
	}
}